<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        let newArr = arr.filter(item => item % 2 === 0)
        console.log(newArr)

        let arr1 = [1, 3, 5, 8]
        let arrFilter = arr1.filter(ele => ele > 4)
        console.log(arrFilter)

        let arrFilter1 = arr1.find(ele => ele > 4)
        console.log(arrFilter1)

        let numbers = [1, 2, 3, 4, 5]
        let doubled = numbers.map(num => num * 2)
        console.log(numbers)
        console.log(doubled)

        let arr3 = arr1.slice(2, 4)
        console.log(arr3)
        let arr4 = arr1.slice(2)
        console.log(arr4)

        let arr7 = [1, 2, 3, 4, 5]
        let result = arr7.reduce((previousValue, currentValue) => {
            return previousValue + currentValue
        }, 10)
        console.log(result)

        let result1 = arr7.reduce((previousValue, currentValue) => {
            return previousValue * currentValue
        })
        console.log(result1)

        let result2 = arr7.reduce((previousValue, currentValue, index, array) => {
            previousValue += currentValue
            if (index === array.length - 1) {
                return previousValue / array.length
            } else {
                return previousValue
            }
        })
        console.log(result2)

        ///数组的遍历
        for (i = 0; i < arr7.length; i++) {
            console.log(arr[i])
        }
        for (item of arr7) {
            console.log(item)
        }
        for (a in arr7) {
            console.log(arr[a])
        }
    </script>

</body>

</html>